package com.yksj.healthtalk.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yksj.healthtalk.entity.MyDoctorListEntity;
import com.yksj.healthtalk.ui.R;
import com.yksj.healthtalk.utils.NineBitMapUtils;

public class NineImageAdapter extends BaseAdapter {

	private Context context;
	private LayoutInflater inflater;
	private ViewHolder holder;
	private NineBitMapUtils bitMapUtils;
	private ArrayList<MyDoctorListEntity> entities;

	public NineImageAdapter(Context context, ArrayList<MyDoctorListEntity> entities) {
		this.context = context;
		inflater = LayoutInflater.from(context);
		bitMapUtils = new NineBitMapUtils(context);
		this.entities = entities;
	}
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return entities.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MyDoctorListEntity entity = entities.get(position);
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.nine_image_list_item, null);
			holder.mHeader = (ImageView) convertView.findViewById(R.id.head_image);
			holder.mName = (TextView)convertView.findViewById(R.id.name);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.mHeader.setImageBitmap(bitMapUtils.createNineImage());
		holder.mName.setText(entity.getName()+"("+entity.getmImageEntity().getNum()+")");
		return convertView;
	}

	class ViewHolder {
		ImageView mHeader;
		TextView mName;
	}

}
